package com.caine.multithread;

import java.util.concurrent.CountDownLatch;

/**
 * @Author: CaineZhu
 * @Description:
 * @Date: Created in 14:01 2020/11/4
 * @Modified By:
 */
public class Demo03 {

    public static void main(String[] args) {
        CountDownLatch latch = new CountDownLatch(1);
        new Thread(()->{
            try {
                latch.await();
                System.out.println(Thread.currentThread() + " exit...");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        new Thread(()->{
            for(int i =1 ;i<=10;i++){

                System.out.println("i = " + i);
                if(i==5){
                    latch.countDown();
                }
            }
        }).start();
    }
}
